package com.example.test;

import java.util.Arrays;

public class LeetCode {

    public static void main(String[] args) {
        int[] nums = {1,1,1};
        int k = 2;
        int result = subarraySum(nums, k);
        System.out.println(result);
    }

    public static int subarraySum(int[] nums, int k) {
        int result=0;
        for(int i=0;i<nums.length;i++){
            int target=k-nums[i];
            if(target==0){
                result+=1;
            }
            for(int second=i+1;second<nums.length;second++){
                target-=nums[second];
                if(target==0){
                    result+=1;
                }
            }
        }
        return result;
    }

}
